package com.wn.main.ui.system.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.wn.common.model.SystemSecondList
import com.wn.framework.adapter.BaseBindViewHolder
import com.wn.framework.adapter.BaseRecyclerViewAdapter
import com.wn.main.databinding.LayoutSystemSecondItemBinding

/**
 * @Author: wn
 * @Date: 2025/5/21 16:51
 * @Description: 体系页中 列表 嵌套 列表 的 adapter
 * adapter 不添加作用域 每一个都是不同的实例
 */
class SystemSecondAdapter :
  BaseRecyclerViewAdapter<SystemSecondList, LayoutSystemSecondItemBinding>() {
  /**
   * 子类通过 xml实现 ViewBinding，父类提供了 LayoutInflater ，viewType
   * 可以根据不同的 viewType传递不同的 viewBinding -- when
   */
  override fun getViewBinding(
    layoutInflater: LayoutInflater,
    parent: ViewGroup,
    viewType: Int,
  ): LayoutSystemSecondItemBinding =
    LayoutSystemSecondItemBinding.inflate(layoutInflater, parent, false)

  /**
   * 子类重写该方法绑定数据
   * 重写 [getViewBinding] 即可实现不同ViewHolder传递
   */
  override fun setViewBinding(
    holder: BaseBindViewHolder<LayoutSystemSecondItemBinding>,
    item: SystemSecondList?,
    position: Int,
  ) {
    item?.apply {
      // 设置标题
      holder.binding.name = name
    }
  }
}